package mortal.game.resource
{
	import Message.Db.Tables.*;
	import com.gengine.resource.*;
	import flash.utils.*;
	
	public class NPCConfig extends Object
	{
		private var _map:Dictionary;
		private static var _instance:NPCConfig;
		
		public function NPCConfig()
		{
			this._map = new Dictionary();
			if (_instance != null)
			{
				throw new Error(" ResConfig 单例 ");
			}
			this.init();
			
		}
		
		private function write(param1:Object) : void
		{
			var _loc_2:TNpc = null;
			var _loc_3:Object = null;
			for each (_loc_3 in param1)
			{
				
				_loc_2 = new TNpc();
				_loc_2.npcId = _loc_3.npcId;
				_loc_2.name = _loc_3.name;
				_loc_2.talk = _loc_3.talk;
				_loc_2.avatarId = _loc_3.avatarId;
				_loc_2.modelId = _loc_3.modelId;
				_loc_2.effectDes = _loc_3.effectDes;
				_loc_2.career = _loc_3.career;
				this._map[_loc_2.npcId] = _loc_2;
			}
			
		}
		
		public function init() : void
		{
			var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_npc.json");
			this.write(_loc_1);
			
		}
		
		public function getInfoByCode(param1:int) : TNpc
		{
			return this._map[param1];
		}
		
		public static function get instance() : NPCConfig
		{
			if (_instance == null)
			{
				_instance = new NPCConfig;
			}
			return _instance;
		}
		
	}
}
